package cn.luowb.checkchat.service.impl;

import cn.luowb.checkchat.common.context.UserContext;
import cn.luowb.checkchat.common.result.Result;
import cn.luowb.checkchat.dao.entity.FollowDO;
import cn.luowb.checkchat.dao.mapper.FollowMapper;
import cn.luowb.checkchat.dao.mapper.UserMapper;
import cn.luowb.checkchat.dto.resp.UserRespDTO;
import cn.luowb.checkchat.service.FollowService;
import cn.luowb.checkchat.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

@Service
public class FollowServiceImpl extends ServiceImpl<FollowMapper, FollowDO>
                              implements FollowService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public Result<UserRespDTO> getFanList(Long userId) {
        Long curId= Objects.equals(userId, UserContext.getUserId()) ?userId:UserContext.getUserId();
        List<FollowDO> userList = query().eq("follow_user_id", curId).list();
        List<Long> ids=userList.stream()
                .map(FollowDO::getUserId)
                .toList();
        //批量查询用户的信息反之n+1查询
        List<UserRespDTO> userRespDTOS=userMapper.getUserList(ids);
        return null;
    }
}
